# -*- coding: UTF-8 -*-


class Task:

    def __init__(self, task_id, requested_image_id, task_feature, start_time):

        self.task_id = task_id
        self.task_arrive_time = task_feature[0]
        self.task_image_name = task_feature[1]
        self.task_cpu = task_feature[2]
        self.task_mem = task_feature[3]
        self.requested_image_id = int(requested_image_id)  # image id

        self.start_time = start_time
        self.assigned_node = None
        self.wait_time = 0

        # 新增参数：记录任务被重调度的次数，初始为0
        self.reschedule_count = 0

        self.task_belong_userid = task_feature[-1]  # type:list

    def __lt__(self, other):
        # 如果reschedule_count相等，等待时间作为第二判断条件
        if self.reschedule_count == other.reschedule_count:
            # 等待时间越长，优先级越高
            return self.start_time < other.start_time
        return self.reschedule_count > other.reschedule_count


if __name__ == "__main__":
    pass
